package App.Repository.impl;

import App.Model.Project.CrmProjectMember;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;
import java.util.Set;

public interface CrmProjectMemberDao extends JpaRepository<CrmProjectMember,String> {
    @Query(value = "SELECT groupid FROM crm_project_member WHERE recstatus = 1 AND userid =?1",nativeQuery = true)

    List<String> getGroupIdsByUserId(int userid);
    @Query( value = " select recid,stageid,groupid,userid,m.projectid,u.realname as username,ismanager,grouptype,innergrouptype,relatedid,ishost " +
            " from crm_project_member m " +
            " inner join crm_user u on m.userid=u.id " +
            " where m.recstatus=1 " +
            " and  projectid in (?1)" +
            " order by m.createtime asc ",nativeQuery = true)
    List<CrmProjectMember> findByProjectId(Set<String> projectIds);
}
